import 'package:cook_dinner/config/include.dart';
import 'package:cook_dinner/widgets/input.dart';
import 'package:flutter/material.dart';

class VerificationInput extends StatefulWidget {
  const VerificationInput({Key? key}) : super(key: key);

  @override
  State<VerificationInput> createState() => _VerificationInputState();
}

class _VerificationInputState extends State<VerificationInput> {
  FocusNode _focusNode = FocusNode();
  TextEditingController _editingController = TextEditingController();
  bool _current = false;

  @override
  void initState() {
    _focusNode.addListener(() {
      if (_focusNode.hasFocus) {
        _current = true;
        setState(() {});
      } else {
        _current = false;
        setState(() {});
      }
    });
    super.initState();
  }

  @override
  Widget build(BuildContext context) {
    return Container(
      width: 60.rpx,
      height: 60.rpx,
      decoration: BoxDecoration(
        borderRadius: BorderRadius.circular(17.rpx),
        color: _current ? Colors.white : const Color(0xfff8f8f8),
        boxShadow: _current
            ? [
                BoxShadow(
                  color: const Color(0xFFBCB4C7).withOpacity(0.5),
                  blurRadius: 8.rpx,
                  spreadRadius: 2.rpx,
                  offset: Offset(0, 13.rpx),
                ),
              ]
            : [],
      ),
      alignment: Alignment.center,
      child: textInput(
        focusNode: _focusNode,
        keyboardType: TextInputType.number,
        fontSize: 30.rpx,
        textAlign: TextAlign.center,
        cursorWidth: 3.rpx,
        cursorColor: Colors.black,
        color: Colors.black,
        hintText: '—',
        color1: _current
            ? Colors.transparent
            : const Color(0xff191632).withOpacity(0.3),
      ),
    );
  }
}
